package huawei;

import java.util.Scanner;
import java.util.Stack;

public class Test_z_001 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            // 注意，如果输入是多个测试用例，请通过while循环处理多个测试用例
            String  str = in.nextLine();
            cover(str);
        }
    }

    private static void cover(String str){
        String[] split = str.split("");
        Stack<String> stack = new Stack<>();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < split.length; ) {
            while (!split[i].equals(" ") && !split[i].equals(",")
                    && !split[i].equals(".") &&!split[i].equals("?")) {
                stack.push(split[i]);
                i++;
                if (i >= split.length) {
                    break;
                }
            }
            while(!stack.isEmpty()){
                sb.append(stack.pop());
            }
            if (i < split.length && (split[i].equals(" ") || split[i].equals(",")
                    || split[i].equals(".") || split[i].equals("?"))) {
                sb.append(split[i]);
            }
            i++;
        }
        System.out.print(sb.toString());
    }
}
